package com.yztc.orangeentertainment.ui.main.findfragment.findmain;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yztc.orangeentertainment.R;
import com.yztc.orangeentertainment.base.BaseActivity;
import com.yztc.orangeentertainment.bean.findbean.FindHotDataListBean;
import com.yztc.orangeentertainment.ui.main.findfragment.findadapter.FindHotAdapter;
import com.yztc.orangeentertainment.ui.main.findfragment.findui.FindContract;
import com.yztc.orangeentertainment.ui.main.findfragment.findui.FindPresenter;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by My on 2016/10/15.
 */
public class FindHotActivity extends BaseActivity implements FindContract.FindHotView {
    @InjectView(R.id.findhot)
    LinearLayout findhot;
    @InjectView(R.id.findhot_rlv)
    RecyclerView findhotRlv;

    public static ImageView findhotIv;
    public static TextView findhotTitle;
    public static ImageView findhotIcon;
    public static TextView findhotName;
    public static TextView findhotNum;
    public static LinearLayout findhotHead;

    private FindContract.Presenter presenter;

    @Override
    public int getLayoutId() {
        return R.layout.find_hot;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.inject(this);
        initView();
    }

    public void initView() {
        //初始化数据
        presenter = new FindPresenter(this);
        presenter.getFindHotDataListBeanFromNet();
        findhotRlv.setLayoutManager(new LinearLayoutManager(this){
            @Override
            public boolean canScrollVertically() {
                return false;
            }
        });

        findhotIv = (ImageView) findViewById(R.id.findhot_iv);
        findhotTitle = (TextView) findViewById(R.id.findhot_title);
        findhotIcon = (ImageView) findViewById(R.id.findhot_icon);
        findhotName = (TextView) findViewById(R.id.findhot_name);
        findhotNum = (TextView) findViewById(R.id.findhot_num);
        findhotHead = (LinearLayout) findViewById(R.id.findhot_head);

        findhot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    public void getFindHotDataListBeanSucess(List<FindHotDataListBean> hotDataListBeens) {
        //热门搜索
        FindHotAdapter adapter = new FindHotAdapter(this, hotDataListBeens);
        findhotRlv.setAdapter(adapter);
    }

    @Override
    public void getFindHotDataListBeanFail(String msg) {

    }
}
